package dao

import (
	"zk/global"
	"zk/internal/model"
)

func CreateLiveRoom(live *model.LiveRoom) bool {
	if err := global.DB.Create(&live).Error; err != nil {
		return false
	}
	return true
}

func GetLiveRoomById(id uint) model.LiveRoom {
	var result model.LiveRoom
	if err := global.DB.Where("id = ?", id).Find(&result); err != nil {
		return model.LiveRoom{}
	}
	return result
}

func GetUpdateLiveRoom(Id uint, room *model.LiveRoom) model.LiveRoom {
	var result model.LiveRoom
	if err := global.DB.Where("id = ?", Id).Updates(&room); err != nil {
		return model.LiveRoom{}
	}
	return result
}

func GetDeleteLiveRoom(room model.LiveRoom) bool {
	if err := global.DB.Model(model.LiveRoom{}).Delete(&room).Error; err != nil {
		return false
	}
	return true
}
